<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>李宁体育管理系统</title>

     <link rel="shortcut icon" href="https://cdns.lining.com/shop/lining/theme/xth2/images/headfooter/favicon.ico">
    <link href="<%=path%>/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/chosen/chosen.css" rel="stylesheet">

    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <link href="<%=path%>/css/animate.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>重置运营者密码</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" method="post" id="signupForm">
                        <input type="hidden" name="id" id="id" value="${user.id }"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">用户名：</label>

                            <div class="col-sm-4">
                                <input class="form-control" type="text" value="${user.userName }" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">密码：</label>

                            <div class="col-sm-4">
                                <input id="userPwd" name="userPwd" class="form-control" type="password" maxlength="32"
                                       placeholder="输入密码" title="密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">确认密码：</label>

                            <div class="col-sm-4">
                                <input id="chkpwd" name="chkpwd" class="form-control" type="password" maxlength="32"
                                       placeholder="输入确认密码" title="确认密码">
                            </div>
                        </div>
                        <p class="m-t-md" style="color: red;display: none" id="errorInfo">sss</p>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                                &nbsp;<button class="btn btn-info" type="button" onclick="goback()">返回</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<%=path%>/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/js/bootstrap.min.js?v=3.3.6"></script>
<script src="<%=path%>/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="<%=path%>/js/contabs.min.js"></script>
<script src="<%=path%>/js/bootstrapValidator.min.js"></script>
<!--下拉框-->
<script src="<%=path%>/js/plugins/chosen/chosen.jquery.js"></script>


<script>
    $(document).ready(function () {
        $('#signupForm').bootstrapValidator({
//            message: 'This value is not valid',
//            feedbackIcons: {
//                valid: 'glyphicon glyphicon-ok',
//                invalid: 'glyphicon glyphicon-remove',
//                validating: 'glyphicon glyphicon-refresh'
//            },
            fields: {
                username: {
                    validators: {
                        callback: {
                            message: '&nbsp;',
                            callback: function (value, validator) {
                                if (value == '') {
                                    document.getElementById("errorInfo").innerHTML = "用户名不能为空";
                                    $("#errorInfo").show();
                                    return false;
                                } else {
                                    document.getElementById("errorInfo").innerHTML = "";
                                    document.getElementById("errorInfo").style.display = 'none';
                                    return true;
                                }

                            }
                        }
                    }
                },
                password: {
                    validators: {
                        callback: {
                            message: '&nbsp;',
                            callback: function (value, validator) {
                                if (value == '') {
                                    document.getElementById("errorInfo").innerHTML = "密码不能为空";
                                    $("#errorInfo").show();
                                    return false;
                                } else {
                                    document.getElementById("errorInfo").innerHTML = "";
                                    document.getElementById("errorInfo").style.display = 'none';
                                    return true;
                                }

                            }
                        }
                    }
                },
                chkpwd: {
                    validators: {
                        callback: {
                            message: '密码不一致',
                            callback: function (value, validator) {
                                if($('#userPwd').val() != null && $('#chkpwd').val() != $('#userPwd').val()){
                                    return false;
                                }
                                return true;
                            }
                        }
                    }
                },
            }
        }).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            // Use Ajax to submit form data

            var temp = {};
            var formParam = $('#signupForm').serializeArray();
            for (var i = 0; i < formParam.length; i++) {
                if (formParam[i].value != '') {
                    temp[formParam[i].name] = formParam[i].value;
                }
            }
            $.post("./editPassword", temp, function (data) {
            	$("#errorInfo").empty();
            	 if ("succese" == data.result) {
                     window.location.href = "<%=path%>/operator/listOpeartor";
                 } else if ("error" == data.result) {
                     document.getElementById("errorInfo").innerHTML = data.msg;
                     $("#errorInfo").show();
                     $("#OPASSWORD").focus();
                 }
                //location.reload();
            });
        });
    });
    function goback() {
    	window.location.href="<%=path%>/operator/listOpeartor";
	}
</script>
</body>
</html>
